/*************************************************************************
 *
 *  Copyright (C) 2013 Florian Dang <florian.coin@gmail.com>
 *
 *  This file is part of NatusVerse.
 *
 *  NatusVerse is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  NatusVerse is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with NatusVerse.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************/

#ifndef INC_LIFE_AUTOMATON_H_
#define INC_LIFE_AUTOMATON_H_

/*!
 * \file        automaton.h
 * \brief       tessellation/cellular, automaton/spaces/structures, iterative arrays...
 * \author      Florian Dang
 * \date        2013
 */

#include <stdio.h>
#include <vector>

#include "life/cell.h"
#include "graphics/graphics.h"

namespace life
{
//! Automaton cellular class
/*!
  Tessellation/cellular, Automaton/spaces/structures, iterative arrays... for Conway's Game of Life
*/
class Automaton
{
	public:
		typedef graphics::Graphics Window;
		typedef std::vector<Cell> VecCell;

		//! default constructor
		Automaton() {}

		//! classic constructor
//		Automaton(  VecCell vec_cell0, int w0, int h0,
//					int wcell0, int hcell0)
//			: vec_cell_(vec_cell0), w_(w0), h_(h0)
//			  w_cell_(wcell0), h_cell(hcell0) {}

		//! classic constructor
		Automaton(int w0, int h0)
			: w_(w0), h_(h0), w_cell_(0), h_cell_(0)
		{
			vec_cell_.resize(w0 * h0);
		}

		//! destructor
		~Automaton() {}

		inline VecCell vec_cell()  const { return vec_cell_; }
		inline int w() const { return w_; }
		inline int h() const { return h_; }
		inline int w_cell() const { return w_cell_; }
		inline int h_cell()  const { return h_cell_; }

//		void ChangeState(const int& i)
//		{
//			vec_cell_[i].set
//		}

		void Initialize(const int& win_w, const int& win_h);

		void CheckGrid(Window win);
		int CheckNeighbors(const int& idx) const;

		void Display(Window win) const;
		void DisplayCell(Window win, const int& idx, const int& winGetH);
		void Print() const;

	private:
		VecCell vec_cell_; /*!< vector cell */
		int     w_;
		int     h_;
		int	    w_cell_;
		int     h_cell_;
};
} // end namespace life
#endif  // INC_LIFE_AUTOMATON_H_
